<!--************************************************************ -->
<!--* 文件创建日期：2010                                  * -->
<!--* 文件修改日期：			                                   * -->
<!--************************************************************ -->
<!--JSP初始化设置-->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.infomanage.po.*" %>
<%@page import="com.qs.po.*"%>
<%@page import="com.qs.vo.*"%>
<%@page import="com.infomanage.vo.*" %>
<%@page import="com.qs.service.*"%>
<%@page import="com.infomanage.util.Consts"%>
<%  response.addDateHeader("Expires", 0);response.setHeader("Pragma","no-cache"); response.setHeader("Cache-Control","no-cache");%>
<%
	request.setCharacterEncoding("UTF-8");
	String itemId = request.getParameter("itemId");
    if(itemId == null) itemId = "";
    QsRecSigninItem item = RecordSigninService.load(request, response, out);
    int deptId = -1;
    String deptName = "";
    String date = "";
    String students = "";
    String place = "";
    String recorder = "";
    String teacher = "";
    String content = "";
    if(item != null){
    	QsRecSignin bean = item.getBean();
    	Department dept = item.getDept();
    	deptId = dept.getDeptId();
    	deptName = dept.getPath();
    	date = bean.getDate();
    	place = bean.getPlace();
    	students = bean.getStudents();
    	teacher = bean.getTeacher();
    	content = bean.getContent();
    }

%>
<html>
<head>
	<title>学习培训签到记录</title>
	<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
	<link href="<%=request.getContextPath() %>/css/style.css" rel="stylesheet" type="text/css">
	<link href="<%=request.getContextPath() %>/css/table.css" rel="stylesheet" type="text/css">
	<link href="<%=request.getContextPath() %>/css/calendar.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/js/calendar.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath() %>/js/common.js"></script>
	<script type="text/javascript">
	   function init() {
		   if("" != "<%=itemId%>") { // 修改
		   }
	   }
	   // 提交
	   function doSubmit(){
	   		if(validate()){
	   			return;
	   		}
		 	if("" == "<%=itemId%>") {
		 		form1.actionType.value = "add";
			}else {
		 		form1.actionType.value = "modify";
			}
		 	form1.submit();
	   }

	   function validate(){
	   		if(form1.deptId.value == ""){
	   			alert("单位不能为空！");
	   			return true;
	   		}

	   		if(form1.date.value == ""){
	   			alert("培训时间不能为空！");
	   			return true;
	   		}

	   		if(form1.teacher.value == ""){
	   			alert("授课人不能为空！");
	   			return true;
	   		}
	   		
	   		if(form1.place.value == ""){
	   			alert("培训地点不能为空！");
	   			return true;
	   		}

	   		if(form1.students.value == ""){
	   			alert("培训人员不能为空！");
	   			return true;
	   		}
	   		return false;
	   }
	   
	   function showError(error){
		   alert(error);
	   }

	   function showInfo(info){
		   alert(info);
		   window.returnValue = "ok";
		   window.close();
	   }

		function showPersonTree(obj){
			var treeFrame = document.getElementById("tree2Frame");
			treeFrame.style.display = "";
			var treeHeight = 200;
			var region = obj.getBoundingClientRect();
			var winWidth = document.body.clientWidth;
			var winHeight = document.body.clientHeight;
			var posX;
			var posY;
			if(treeHeight + region.bottom > winHeight && !isDown){
				posX = region.left;
				posY = region.top - treeHeight;
			}else {
				posX = region.left;
				posY = region.bottom;
			}
			treeFrame.style.left = posX;
			treeFrame.style.top = posY;
			treeFrame.style.width = obj.clientWidth;
			treeFrame.style.height = treeHeight;
		}

		function onCheckboxClick(nodeObj){
			var existPersonName = form1.students.value;
			var nodePersonName = nodeObj.nodeName;
			var existPersonNameArray = existPersonName.split(";");
			var isHasFlag = false;
			for(var i = 0; i < existPersonNameArray.length; i++){
	             if(existPersonNameArray[i] == nodePersonName){
	                 isHasFlag = true;
	                 break;
	             }
			}
			if(isHasFlag){
				existPersonNameArray.remove(i);
			}
			else{
	 			if(existPersonNameArray[0] == "" || typeof(existPersonNameArray[0]) == 'undefined'){
	 			   existPersonNameArray = new Array();
	 	 		 }
			     existPersonNameArray.push(nodePersonName);
			}
			form1.students.value = existPersonNameArray.join(";");
			form1.students.title = form1.students.value;
		}

		function clickBody() {
			if(event == null){
				document.getElementById("treeFrame").style.display = "none";
				document.getElementById("tree2Frame").style.display = "none";
				return;
			}
			var srcObj = event.srcElement;
			var treeFrame = document.getElementById("treeFrame");
			var tree2Frame = document.getElementById("tree2Frame");
			if(srcObj.treeSelect == "true"){
				
			}else {
				treeFrame.style.display = "none";
				tree2Frame.style.display = "none";
			}
		}
	</script>
</head>
<body  rightmargin="0" bottommargin="0" leftmargin="0" topmargin="0"  onload="init();" onclick="clickBody();">
	<form name="form1" action="signin_action.jsp" method="post" target="actionFrame">
	<input type="hidden" name="itemId" value="<%=itemId%>">
	<input type="hidden" name="actionType">
	
	<table class="dialogTable" cellpadding="0" cellspacing="0">
		<!-- 表头-->
		<tr class="dialogTableHeader">
			<td>学习培训签到记录</td>
		</tr>
		<!-- 表数据-->
		<tr class="dialogTableContent">
			<td>
				<!-- 数据项 -->
				<table class="dataTable">
					<col width="30%">
					<col width="70%">
					<tr>
						<td class="field" >
							单位
						</td>
						<td>
							<span class="treeSpan" onclick="showTree(this, '<%=request.getContextPath() %>/infomanage/common/deptTree.jsp');" treeSelect="true">
								<input name="deptname" style="width: 100%;" readonly="readonly" 
								treeSelect="true" value="<%=deptName %>"><input name="deptId"  type="hidden" value="<%=deptId %>">
							</span>
						</td>
					</tr>
					<tr>
						<td class="field" >
							培训时间
						</td>
						<td>
							<input  type="text" name="date" value="<%=date %>"  style="width: 230px;cursor: hand;" id="beginTime" onClick="return showCalendar(this.id, 'y-mm-dd');" readonly="readonly"><img 
									src="<%=request.getContextPath() %>/img/tip_calender.gif" style="cursor: hand;" width="16" height="16" onClick="return showCalendar('time', 'y-mm-dd');">
						</td>

					</tr>
					<tr>
						<td class="field" >
							授课人
						</td>
						<td>
							<span class="treeSpan" onclick="showTree(this, '<%=request.getContextPath() %>/infomanage/common/personTree.jsp');" treeSelect="true">
								<input name="teacher"  value="<%=teacher %>"  style="width: 100%;" readonly="readonly" 
								treeSelect="true"><input type="hidden">
							</span>
						</td>

					</tr>
					<tr>
						<td  class="field" >
							培训地点
						</td>
						<td>
							<input value="<%=place %>" name="place" style="width: 100%;"/>
						</td>
					</tr>
					<tr>
						<td  class="field" >
							参加培训人员
						</td>
						<td>
							<span class="treeSpan" onclick="showPersonTree(this);" treeSelect="true">
								<input name="students"  value="<%=students %>"  style="width: 100%;" readonly="readonly" 
								treeSelect="true"><input type="hidden">
							</span>
						</td>
					</tr>
					<tr height="300px">
							<td class="field" >
								培训内容
							</td>
							<td height="300px">
								<textarea name="content" style="width: 100%;height: 100%"><%=content %></textarea>
							</td>
						</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="tableBtn">
				<span onclick="doSubmit();">确定</span>
				<span onclick="window.close();">取消</span>
			</td>
		</tr>
		<tr valign="top">
			<td colspan="2">
				&nbsp;
			</td>
		</tr>
	</table>
	</form>
	<iframe src="#" frameborder="0" id="treeFrame" name="frame" style="display: none;position: absolute;"></iframe>
	<iframe src="<%=request.getContextPath()%>/infomanage/common/personSelectTree.jsp" frameborder="0" id="tree2Frame" name="tree2Frame" style="display: none;position: absolute;"></iframe>
	<iframe src="#" name="actionFrame" style="display: none;"></iframe>
</body>
</html>